﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ChoViet.Lib.Common
{
    public class LinkUtils
    {
        public static string UrlImageOrDefault(string imagepath)
        {
            if (string.IsNullOrEmpty(imagepath)) return "/Images/iconC102.png";
            else return imagepath;
        }
        public static string ShopImageOrDefault(string imagepath)
        {
            if (string.IsNullOrEmpty(imagepath)) return "/Images/noavatar.jpg";
            else return imagepath;
        }
        public static readonly string domain = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);
        public static string AvataOrDefault(string avataPaht)
        {
            if (string.IsNullOrEmpty(avataPaht)) return "/Images/noavatar.gif";
            else return avataPaht;
        }
        public static string UrlAdIndexDefault(string demandShortName, string CateShortName, string cityShortName, string AdtributeShortName, string adtributeValueShortName, int cusTypeId)
        {
            var link = string.Format("/{0}/{1}/{2}/{3}/{4}/{5}", string.IsNullOrEmpty(demandShortName) ? "mua-ban" : demandShortName,
                string.IsNullOrEmpty(CateShortName) ? "hang-hoa" : CateShortName, string.IsNullOrEmpty(cityShortName) ? "ca-nuoc" : cityShortName,
                string.IsNullOrEmpty(AdtributeShortName) ? "thong-tin" : AdtributeShortName,
                string.IsNullOrEmpty(adtributeValueShortName) ? "lien-he" : adtributeValueShortName, cusTypeId >0 ? cusTypeId : 0);
            return link;
        }
        public static string UrlAdIndexDefault(string demandShortName, string CateShortName, string cityShortName,string countryShortName, string AdtributeShortName, string adtributeValueShortName, int cusTypeId)
        {
            var link = string.Format("/{0}/{1}/{2}/{3}/{4}/{5}", string.IsNullOrEmpty(demandShortName) ? "mua-ban" : demandShortName,
                string.IsNullOrEmpty(CateShortName) ? "hang-hoa" : CateShortName, string.IsNullOrEmpty(cityShortName) ? "Tat-ca" : cityShortName + "-" + countryShortName,
                string.IsNullOrEmpty(AdtributeShortName) ? "thong-tin" : AdtributeShortName,
                string.IsNullOrEmpty(adtributeValueShortName) ? "lien-he" : adtributeValueShortName, cusTypeId > 0 ? cusTypeId : 0);
            return link;
        }
    }
}
